# 项目域名
BASE_URL = 'http://user-p2p-test.itheima.net'

# 项目路径
import os
import logging.handlers

BASE_LJ = os.path.dirname(os.path.abspath(__file__))


# 日志初始化配置
def init_log_config(filename):
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    st = logging.StreamHandler()
    fh = logging.handlers.TimedRotatingFileHandler(filename, when='midnight',
                                                   interval=1, backupCount=7,
                                                   encoding='utf8')
    fmt = "%(asctime)s %(levelname)s %(name)s [%(filename)s (%(funcName)s : %(lineno)d)] - %(message)s"
    format = logging.Formatter(fmt)
    st.setFormatter(format)
    fh.setFormatter(format)
    logger.addHandler(st)
    logger.addHandler(fh)


if __name__ == '__main__':
    init_log_config(BASE_LJ + '\log\p2p.log')
    logging.info('我无敌')
    print(BASE_LJ)
